package com.hundsun.documentripper.domain.dto;

import java.io.Serializable;

import com.hundsun.documentripper.error.ErrorMessage;

import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * Note：
 *
 * @author ：mengjw
 * @description：统一基础返回对象
 * @date ：Created in 2021/1/26
 */
@Data
@NoArgsConstructor
public class BaseResponse<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer returnCode = 0;
    private String errorCode = "";
    private String errorMessage = "";
    private T result;

    public BaseResponse(T result) {
        this.result = result;
    }

    public static BaseResponse buildErrorResponse(String errorCode) {
        BaseResponse baseResponse = new BaseResponse();
        baseResponse.setReturnCode(-1);
        baseResponse.setErrorCode(errorCode);
        baseResponse.setErrorMessage(ErrorMessage.getMessage(errorCode));
        return baseResponse;
    }

}